#ifndef __THREADPOOL_H
#define __THREADPOOL_H
#include "noncopyable.hpp"
#include "thread.hpp"
#include "taskqueue.hpp"
#include <vector>
#include <memory>
#include <functional>
using std::vector;
using std::unique_ptr;
using std::function;
using std::bind;
namespace moqi
{
using Taskfun = function<void()>;
class Threadpool:public Noncopyable
{
    friend class Mythread;
public:
    Threadpool(int threadNum, int queSize);
    ~Threadpool();
    void start();
    void stop();
    void addTask(Taskfun && tcb);
private:
    void doTask();
private:
    vector<unique_ptr<Thread>> _threads;
    int _threadNum;
    int _queSize;
    TaskQueue _que;
    bool _isExit;
};
}
#endif
